﻿using System;
using System.Collections.Generic;

using MonPocGarage.ArmyContracts.Common;
using MonPocGarage.ArmyContracts.Common.Enums;
using MonPocGarage.ArmyContracts.Common.Stats;

namespace MonPocGarage.ArmyContracts
{
    public class Monster : ICloneable
    {
        public string MonsterName { get; set; }

        public string MonsterID
        {
            get { return MonsterFamily.Replace(" ", string.Empty) + "_" + MonsterType; }
        }

        public Guid InstanceKey { get; private set; }

        public string ImagePath { get { return BuildImagePath(); } }

        public MonsterType MonsterType { get; set; }

        public string MonsterFamily { get; set; }

        public Faction Faction { get; set; }

        public Agenda Agenda { get; set; }

        public StatBlock Stats { get; set; }

        public PowerStat Power { get; set; }

        public int Health { get; set; }

        public List<IAbility> Abilities { get; set; }

        public int HyperCost { get; set; }

        public EnergyType EnergyType { get; set; }

        public Monster()
        {
            InstanceKey = Guid.NewGuid();
            //ImagePath = BuildImagePath();
        }

        private Monster(Monster another)
        {
            MonsterName = another.MonsterName;
            InstanceKey = Guid.NewGuid();
            MonsterType = another.MonsterType;
            MonsterFamily = another.MonsterFamily;
            Faction = another.Faction;
            Agenda = another.Agenda;
            Stats = another.Stats;
            Power = another.Power;
            Health = another.Health;
            Abilities = another.Abilities;
            HyperCost = another.HyperCost;
            EnergyType = another.EnergyType;
            //ImagePath = BuildImagePath();
        }

        private string BuildImagePath()
        {
            if (!string.IsNullOrWhiteSpace(MonsterName))
            {
                string imagePath = string.Format("{0}/Images/Monsters/{1}/{2}_{3}.png",
                                             Environment.CurrentDirectory,
                                             Faction,
                                             MonsterFamily.ToLower(),
                                             MonsterType.ToString().ToLower());
                return imagePath;
            }
            return string.Empty;
        }

        public object Clone()
        {
            return new Monster(this);
        }
    }
}
